#include <bits/stdc++.h>
using namespace std;
int cnt[100005];
int cnt1[100005];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        cnt[x]++;
        cnt1[x]++;
    }
    //cout<<cnt[1]<<' '<<cnt[2]<<endl;
    cnt[100003]=1000000000;
    cnt1[100003]=1000000000;
    cnt[100002]=1000000000;
    cnt1[100002]=1000000000;
    int ind1=0,ind2=0;
    while(!cnt[ind1])ind1++;
    ind2=ind1+1;
    while(!cnt[ind2])ind2++;
    while(ind2<=100000){
        cnt[ind1]--;n--;
        cnt1[ind2]--;
        while(!cnt[ind1])ind1++;
        ind2=max(ind2,ind1+1);
        while(!cnt1[ind2])ind2++;
    }
    cout<<n<<endl;
    fclose(stdin);
    fclose(stdout);
    return 0;
}